package com.ccp.dev.form.service;

import com.ccp.dev.core.basic.base.BaseService;
import com.ccp.dev.form.dao.SubTableRightsDao;
import com.ccp.dev.form.model.SubTableRights;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;


/**
 *<pre>
 * 对象功能:子表权限 Service类
 * 开发人员:wwz
 * 创建时间:2013-01-16 10:04:39
 *</pre>
 */
@Service
public class SubTableRightsService extends BaseService<SubTableRights> {
    @Resource
    private SubTableRightsDao subTableRightsDao;

    /**
     * 根据流程ID和节点ID获取子表权限配置
     * @param procDefId 流程定义Id
     * @param nodeId 节点id
     * @param subTableId 子表id
     * @return 子表权限
     */
    public SubTableRights getByProcDefIdAndNodeId(String procDefId, String nodeId, String subTableId) {
        Map<String, Object> params = new HashMap<>(3);
        params.put("procDefId", procDefId);
        params.put("nodeId", nodeId);
        params.put("tableId", subTableId);
        return subTableRightsDao.getByProcDefIdAndNodeId(params);
    }

    /**
     * 根据流程ID和节点ID和父流程ID获取子表权限配置
     * @param procDefId 流程定义id
     * @param nodeId 节点id
     * @param subTableId 子表id
     * @param parentProcDefId 父流程定义id
     * @return 子表权限
     */
    public SubTableRights getByProcDefIdAndNodeIdAndParent(String procDefId, String nodeId, String subTableId, String parentProcDefId) {
        Map<String, Object> params = new HashMap<>(3);
        params.put("procDefId", procDefId);
        params.put("nodeId", nodeId);
        params.put("tableId", subTableId);
        params.put("parentProcDefId", parentProcDefId);
        return subTableRightsDao.getByProcDefIdAndNodeIdAndParent(params);
    }
}
